Skip to content

Fix Python XML nullable result declarations - #209

Merged
leileizhang (lei9444) merged 3 commits into
mainfrom
lei9444-fix-python-xml-nullability
Oct 8, 2026
Merged

leileizhang (lei9444) merged 3 commits into
mainfrom
lei9444-fix-python-xml-nullability

Conversation

@lei9444

@lei9444 leileizhang (lei9444) commented Oct 1, 2026 •

Copy link
Copy Markdown
Contributor

Problem

Some Python XML DOM stubs declare non-null results that Windows returns as None. Strict mypy and Pyright accept XmlDocument().document_element.tag_name, although an empty document raises AttributeError.

Fix and compatibility

Add reviewed nullable facts for document root/DTD, node ownership/navigation and attribute lookup/replacement results. Exact aliases connect documented runtime-class members to their declaring interfaces, with SDK owner and full signature validation. The fact table is regenerated reproducibly from the existing pinned official documentation.

Only the affected XML .pyi results become nullable: callers must guard them before dereferencing. Runtime null conversion, inline/--no-pyi behavior, the general nullability policy and JavaScript output are unchanged. This does not add explicit CLI-root support for exclusive IXmlDocument/IXmlElement interfaces.

Verification

  • Strict mypy/Pyright reject 20 previously unsafe accesses and accept guarded reads and non-null controls.
  • ARM64 and x64 native tests cover empty/loaded/DTD documents, detached nodes, sibling boundaries, and missing/new/replaced attributes, including namespace-aware variants.
  • The tested output changes only 13 XML .pyi modules; 372 Python runtime modules and 296 JS/ESM/TypeScript files remain byte-identical.
  • Final-head Build, coverage and Python artifact checks passed, including the enforced installed-runtime XML and strict-checker lane.

Local x64 tests use Windows ARM64 emulation. Test harnesses use native SDK contracts and tracked or independently installed stubs; no ignored build artifacts are required.

leileizhang (lei9444) and others added 2 commits October 1, 2026 22:25
Record exact reviewed Windows XML null results and declaring-interface aliases in the pinned documentation extraction flow. Cover SDK owner/signature matching, strict consumers, and scoped native XML states without changing runtime or JS output.

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
CI-only compatibility: accept optional trailing commas and format the two existing audio stub macro calls required by hosted Rust 1.99. Apply only the explicitly reviewed fixture delta; native signatures, function bodies, and XML product changes are unchanged.

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
@github-actions

github-actions Bot commented Oct 1, 2026 •

Copy link
Copy Markdown

Mixed-language test coverage

Workflow status: ✅ Passed

Layer Lines Functions Branches/regions
Rust, including native .pyd/.node 86.92% 82.48% 86.65% regions
Python aggregate 72.34% n/a 39.42% branches
Python runtime 98.17% n/a 94.57% branches
Generated Python WinRT projections 71.07% n/a 33.5% branches
Generated Python WinRT implementations 71.97% n/a 46.3% branches
JavaScript aggregate 21.91% 25.18% 57.61% branches
JavaScript runtime 44.27% 45.76% 78.99% branches
Generated WinRT projections 22.8% 18.7% 54.84% branches
Generated WinRT implementations 45.99% 59.19% 60.97% branches
Generated Classic COM projections 11.88% 23.97% 53.4% branches

View workflow run and download full HTML/LCOV/XML reports

Use the native SDK contract shared by null-fact tests instead of the unrelated CLR Facade override used by TypeScript jobs, and reuse existing sibling expansion. Exercise source stubs in pre-wheel static phases, preserve extra source paths, and additionally typecheck installed runtime stubs when present. Keep native XML and strict checker requirements enforced in the production E2E lane.

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
@lei9444
leileizhang (lei9444) merged commit e97fa38 into main Oct 8, 2026
33 checks passed
@lei9444
leileizhang (lei9444) deleted the lei9444-fix-python-xml-nullability branch October 8, 2026 08:52
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants